package com.wstx.mediaserver.util;

import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.OutputFile;
import com.baomidou.mybatisplus.generator.config.TemplateType;

import java.util.Collections;

public class CodeGenerator {

    public static void main(String[] args) {
        FastAutoGenerator.create("jdbc:mysql://127.0.0.1:3306/vdos_tsp?autoReconnect=true&useServerPreparedStmts=false&rewriteBatchedStatements=true&characterEncoding=UTF-8&useSSL=false&allowMultiQueries=true&serverTimezone=UTC&allowPublicKeyRetrieval=true",
                "root", "wstx3306")
                .globalConfig(builder -> {
                    builder.author("凌华小乌龟") // 设置作者
//                            .enableSwagger() // 开启 swagger 模式
                            .fileOverride() // 覆盖已生成文件
                            .outputDir("E:\\Idea Projects\\Work\\MediaServer\\src\\main\\java\\com\\wstx"); // 指定输出目录
                })
                .packageConfig(builder -> {
                    builder.parent("mediaserver") // 设置父包名
                            .pathInfo(Collections.singletonMap(OutputFile.mapperXml, "E:\\Idea Projects\\Work\\MediaServer\\src\\main\\resources\\mapper")); // 设置mapperXml生成路径
                })
                .strategyConfig(builder -> {
                    builder.addInclude("ws_file") // 设置需要生成的表名
                            .addTablePrefix("ws") // 设置过滤表前缀
                            .entityBuilder()
                            .enableLombok();
                })
                .templateConfig(builder -> {
                    builder.disable(TemplateType.CONTROLLER,
                            TemplateType.SERVICE,TemplateType.SERVICEIMPL);
                })
                .execute();
    }
}
